﻿using System;
using yiCommerce.Core.Data;
using yiCommerce.Core.Domain.Shippings;
using yiCommerce.Core.Domain.ShoppingCarts;

namespace yiCommerce.Service.Shippings
{
    public class ShippingService:IShippingService
    {
        private IRepository<Shipment> shipmentRep;


        public ShippingService(IRepository<Shipment> shipmentRep)
        {
            this.shipmentRep = shipmentRep;
        }

        public decimal GetShoppingCartItemWeight(ShoppingCartItem sc)
        {
            return (decimal) 1.0;
        }

        public int SetShipped(int orderId, string trackNo)
        {
            var shipment = new Shipment()
                {
                    CreatedOn = DateTime.Now,
                    OrderId = orderId,
                    TrackingNo = trackNo


                };
            shipmentRep.Insert(shipment);


            
            return shipment.Id;
        }
    }
}